package com.thtf.homework.service.Impl;

import com.thtf.homework.mapper.DataCatMapper;
import com.thtf.homework.model.DataCat;
import com.thtf.homework.service.DataCatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;

@Service
public class DataCatServiceImpl implements DataCatService {
    @Autowired
    private DataCatMapper dataCatMapper;

    // 查询数据目录
    @Override
    public List<DataCat> queryDataCat() {
        List<DataCat> dataCats = dataCatMapper.queryDataCat();
//        System.out.print(dataCats);
        return dataCats;

    }

    @Override
    public void createDataCat(String pid, String dataCatName) {
        if (pid.equals("0"))
            dataCatMapper.createDataCatP(UUID.randomUUID().toString(), dataCatName, pid);
        else
            dataCatMapper.createDataCatC(UUID.randomUUID().toString(), dataCatName, pid);

    }

    @Override
    public void renameDataCat(String dataCatId, String dataCatName) {
        dataCatMapper.renameDataCat(dataCatId, dataCatName);
    }

    @Override
    public void delDataCat(String dataCatId) {
        dataCatMapper.delDataCat(dataCatId);
    }
}
